<template>
  <scroll-view scroll-y="true" class="my-exer">
<!--    <view class="name">
      {{ userStore.name }}({{}})
    </view> -->
    <uni-section title="正式考试" type="line">
      <uni-list class="list_content">
        <uni-list-item>
          <template v-slot:body>
            <view class="slot-box">
              <span class="slot-text"
                >正在进行的考试：<span style="color: #25b864"
                  >{{ statis.jxZsExam }}场</span
                ></span
              >
            </view>
          </template>
        </uni-list-item>
        <uni-list-item>
          <template v-slot:body>
            <view class="slot-box">
              <span class="slot-text">
                正式考试总场数：<span style="color: #24b0fb"
                  >{{ statis.allZsExam }}场</span
                >
              </span>
            </view>
          </template>
        </uni-list-item>
        <uni-list-item>
          <template v-slot:body>
            <view class="slot-box">
              <span class="slot-text">
                正式考试平均分：<span style="color: #ff9933"
                  >{{ statis.avgZsExam }}分</span
                >
              </span>
            </view>
          </template>
        </uni-list-item>
      </uni-list>
    </uni-section>
    <uni-section title="模拟考试" type="line">
      <uni-list class="list_content">
        <uni-list-item>
          <template v-slot:body>
            <view class="slot-box">
              <span class="slot-text"
                >正在进行的考试：<span style="color: #25b864"
                  >{{ statis.jxMockExam }}场</span
                ></span
              >
            </view>
          </template>
        </uni-list-item>
        <uni-list-item>
          <template v-slot:body>
            <view class="slot-box">
              <span class="slot-text">
                模拟考试总场数：<span style="color: #24b0fb"
                  >{{ statis.allMockExam }}场</span
                >
              </span>
            </view>
          </template>
        </uni-list-item>
        <uni-list-item>
          <template v-slot:body>
            <view class="slot-box">
              <span class="slot-text">
                模拟考试平均分：<span style="color: #ff9933"
                  >{{ statis.avgMockExam }}分</span
                >
              </span>
            </view>
          </template>
        </uni-list-item>
      </uni-list>
    </uni-section>
  </scroll-view>
</template>
  
  <script lang="ts" setup>
import { reactive, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import http from "@/utils/request";

// 定义变量

const statis = reactive({
  // 首页统计
  jxZsExam: "", // 正在正式考试数量
  jxMockExam: "", // 正在模拟考试数量
  allMockExam: "", // 总模拟考试数量
  allZsExam: "", // 总正式考试数量
  resource: "", // 资源数量
  avgZsExam: "", // 平均正式考试分数
  avgMockExam: "", // 平均模拟考试分数
});
// 页面加载完毕，执行如下方法
onLoad(async () => {
  statisQuery();
});

// 统计查询
async function statisQuery() {
  let { data, code } = await http.post("search/homeStat", {}); // 首页统计
  if (code) uni.stopPullDownRefresh();
  statis.jxZsExam = data.jxZsExam;
  statis.jxMockExam = data.jxMockExam;
  statis.allMockExam = data.allMockExam;
  statis.allZsExam = data.allZsExam;
  statis.resource = data.resource;
  statis.avgZsExam = data.avgZsExam?data.avgZsExam:0;
  statis.avgMockExam = data.avgMockExam?data.avgMockExam:0;
}
</script>
  
  <style lang="scss" scoped>
.name {
  font-size: 16px;
  font-weight: 500;
  color: #000;
  text-align: center;
  margin-top: 20rpx;
  margin-bottom: 20rpx;
}

.my-exer {
  height: 100%;
}
/* 固定高度，超出滚动*/

.list_content {
  overflow-y: auto;
}
/* 卡片圆角 阴影效果*/
.card {
  margin: 15rpx;
  background-color: #fff;
  border-radius: 20rpx;
  box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, 0.1);
}
.test_time {
  height: 60rpx;
  margin: 6rpx;
  display: flex;
  flex-direction: column;
  align-items: left;
  justify-content: center;
}
.test_card_status {
  height: 60rpx;
  margin: 6rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
</style>
  <style scoped>
.uni-list-item /deep/ .uni-list-item__content-title {
  font-size: 16px;
  color: #000;
  font-weight: 500;
}
</style>
  